/**
 * Created by ZHOUSH on 1/6/2016.
 */
var foundClz = function (dom, filter) {
    return dom.className.split(/\s+/ig).filter(filter);
};
dashboard.controller('dashboardController', function ($scope, $http) {
    $scope.criteria = {
        select: ['B'],
        cb0: [true],
        cb1: [true]
    };
    $scope.layout = {
        frame: false,
        size: [12, 9],
        panels: [{
            heading: 'Title',
            size: [2, 9],
            form: {
                options: ['A','B','C'],
                data: $scope.criteria,
                fields: [
                    '[inline,@select,multi]Field0=>select,@options|text',
                    'Field1=>text|text|text',
                    '-',
                    '[block,multi,@ta]Field Select=>textarea|text',
                    '-',
                    '[@op0]Options=>radio,Option 00,g0,op00',
                    '[@op0]=>radio,Option 01,g0,op01',
                    '[@op1]Options=>radio,Option 10,g1,op10',
                    '[@op1]=>radio,Option 11,g1,op11',
                    '-',
                    '[@cb0]Checkbox=>checkbox,Value1',
                    '[@cb1,noLabel]=>checkbox,Value2',
                    '-',
                    '[@list,block]Test ListView=>listview,@options,box',
                    '-',
                    '[buttons,left]=>button,Save|button,Cancel'
                ]
            },
            items: [
                'form=>@panel.form'
            ]
        }, {
            heading: 'Title',
            size: [2, 9],
            form: {
                data: {},
                fields: [
                    'Field0=>text|number',
                ]
            },
            items: [
                '<db-form db-bind="panel.form"></db-form>'
            ]
        }, {
            //frame: false,
            heading: 'Result',
            size: [8, 9],
            data: {
                metaData: {
                    columns: ['a', 'b', 'c', 'd', 'e', 'f']
                },
                rows: [
                    {
                        a: 1, b: 2, c: 3, d: 4, e: 5, f: 6
                    },
                    {
                        a: 1, b: 2, c: 3, d: 4, e: 5, f: 6
                    }
                ]
            },
            items: [
                '<db-table db-bind="panel.data"></db-table>'
            ]
        }]
    };
    var rc = function (panel) {
        if (panel.panels) {
            panel.panels.forEach(function (item) {
                item.parent = panel;
                rc(item);
            })
        }
    };
    rc($scope.layout);
    $scope.query = function () {
        $http.post('/api/query', {
            sql: 'select sql_str from HLLP_OBJ_ADMIN.llp_rpt_oracle_jxls where ora_rpt_rdf_name = \'RPT_ICS_INVOICE_GY\' and sheet_no = 2'
        }).success(function () {
            console.log(1);
        });
    }
});